<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../css/style.css">
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <!-- 引入组件库 -->
    <script src="../js/vue.js"></script>
    <script src="../js/axios-0.18.0.js"></script>
    <script src="../plugins/echarts/echarts.min.js"></script>
    <script src="../plugins/elementui/index.js"></script>
</head>
<body class="hold-transition">
<div id="app">
    <div class="block">
        <span class="demonstration">点击选择日期区间</span>
        <el-date-picker
                @change="order()"
                v-model="value1"
                type="daterange"
                value-format="yyyy-MM-dd"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期">
        </el-date-picker>
    </div>
    <div class="content-header">
        <h1>统计分析<small>套餐收入统计</small></h1>
    </div>
    <div class="app-container">
        <div class="box">
            <!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->
            <div id="chart1" style="height:600px;"></div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    // 使用刚指定的配置项和数据显示图表。
    //myChart.setOption(option);
    var vue = new Vue({
        el: '#app',
        data: {
            value1:[],
        },
        created(){
            this.order();
        },
        methods:{
            order(){
                axios.post("/report/getSetmealPrice.do",this.value1).then((res)=>{
                    // 基于准备好的dom，初始化echarts实例
                    //初始化实例需要和设置option放在一起
                    var myChart1 = echarts.init(document.getElementById('chart1'));
                    myChart1.setOption(
                        {
                            tooltip: {
                                trigger: 'item',
                                formatter: '{a} <br/>{b}: {c} ({d}%)'
                            },
                            legend: {
                                orient: 'vertical',
                                left: 10,
                                //套餐类型
                                data: res.data.data.setmealNames
                            },
                            series: [
                                {
                                    name: '访问来源',
                                    type: 'pie',
                                    radius: ['50%', '70%'],
                                    avoidLabelOverlap: false,
                                    label: {
                                        show: false,
                                        position: 'center'
                                    },
                                    emphasis: {
                                        label: {
                                            show: true,
                                            fontSize: '30',
                                            fontWeight: 'bold'
                                        }
                                    },
                                    labelLine: {
                                        show: false
                                    },
                                    //套餐对应的收入
                                    data: res.data.data.setmealCount
                                }
                            ]
                        }
                       );
                });
            }
        }
    });
</script>
</html>